<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="./css/font.css">
<link rel="stylesheet" href="./css/xadmin.css">
<!-- <link rel="stylesheet" href="./css/theme5.css"> -->
<script src="./lib/layui/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="./js/xadmin.js"></script>
<script type="text/javascript" src="./js/jquery.min.js"></script>
<title>修改密码</title>
</head>
<style type="text/css">
.layui-form{
	width:50%;
	height:100px;
	margin:80px auto;
	
}
.layui-input-block input{
	width:60%;
}
.layui-input-block input{
	float: left;
}
.btn{
	margin-top:30px;
}
</style>
<body>
	<form class="layui-form" action="" id="form">
		<div class="layui-form-item">
                <label class="layui-form-label">新&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;密&nbsp;&nbsp;&nbsp;&nbsp;码</label>
                <div class="layui-input-block">
                    <input type="password" name="stu_name" id="stu_name" required  lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input stu_name">
                </div>
            </div>
        <div class="layui-form-item">
                <label class="layui-form-label">确&nbsp;认&nbsp;&nbsp;密&nbsp;&nbsp;码</label>
                <div class="layui-input-block">
                    <input type="password" name="stu_name2" id="stu_name2" required  lay-verify="required" onblur="sure()" placeholder="请再次输入新密码" autocomplete="off" class="layui-input stu_name">
                	<span id="tips"></span>
                </div>
            </div>
       <div class="layui-form-item">
               <div class="layui-input-block buttonOne">
                   <button class="btn layui-btn" lay-filter="formDemo" onclick="passsubmit()">修改密码</button>
               </div>
        </div>
	</form>
</body>
<script>
var key = 0;
function sure(){
	//alert('q111');
	var pas1=$('#stu_name').val();
	var pas2=$('#stu_name2').val();
	if(pas1!=pas2){
		$("#tips").html("两次密码不同");
		$('#tips').css('color','red');
		return key=0;
	}else{
		return key=1;
	}
}
function passsubmit(){
	//alert(key);
	if(key==1){
		var url = "${pageContext.request.contextPath}/updatePwd";
		var param = {"stu_name2":$('#stu_name2').val()};
		//param= decodeURIComponent(param,true);
		$.post(url,param,function (data){
			if(data.flag==0){
				alert(data.msg);
			}
			if(data.flag==1){
				window.parent.locattion.reload();
				var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
		        parent.layer.close(index);
		        alert(data.msg);
			}
		})

	}
}
</script>
</html>